
*****
*****
*****
*****code w merged data
***would be good to make a bar chart comparing different races and their distribution of answers to questions
***what about people who are like 25% latino? are they the main attritors? do we care if they are 25% latino or is that irrelevant? who is actually checking the ethnic attriton box? 

***2020 post qx: white people have certain advantages, racial problems are rare and isolated, blacks should do the same, i resent when whites deny the existence (441e), whites do not go to great lengths. Note that 441e-g is only shown if race != white
***question: is 441e only shown to non white people in 2022? because white attritors also had to answer - maybe they include anyone who says hispanic too???? Other questions probably better

**for 2018 it is linked by CC18_422 not 441

**for 2016 the white people have advantages is CC16_422d, racial problems are rare isolated incidents is CC16_422f,

**for 2014 it is CC422a for prejudice and CC 422b for hard to get out

**for 2012 it is CC422a and b for overcome prejudice and hard to get out 

**for 2010 it is CC422a and b for prejduice and hard to get out

**rename 2022 data
use "/Users/sierravaldez/Downloads/CCES22_Common_OUTPUT_vv_topost.dta",clear
rename gender4 gender
rename CC22_440a wyt_ppl_adv
rename CC22_440b rare_iso
rename CC22_441a overcome_prejudice
rename CC22_441b gen_slavery
rename CC22_441e resent
save renamed_CCES22.dta, replace
**rename 2020 data
use "/Users/sierravaldez/Downloads/CES20_Common_OUTPUT_vv.dta"
rename CC20_440a wyt_ppl_adv
rename CC20_440b rare_iso
rename CC20_441a overcome_prejudice
rename CC20_441b gen_slavery
rename CC20_441e resent
save renamed_CCES20.dta, replace
**rename 2018 name
use "/Users/sierravaldez/Downloads/cces18_common_vv.dta"
rename CC18_422a wyt_ppl_adv
rename CC18_422b rare_iso
rename CC18_422e overcome_prejudice
rename CC18_422f gen_slavery
save renamed_CCES18.dta, replace

use "renamed_CCES22.dta"
append using "renamed_CCES20.dta", force
save mergeddata.dta, replace

use mergeddata.dta, replace
append using "renamed_CCES18.dta", force
save mergeddata.dta, replace

svyset [pweight=commonweight]

*add year
gen year = .
replace year = 2022 if CC22_300_1 != .
replace year = 2020 if CC20_303 != .
replace year = 2018 if CC18_302 != .

*attritor
gen attritor = 0
replace attritor = 1 if race != 3 & hispanic == 1

*attritor, not mixed race
gen attritor_single_race = 0
replace attritor_single_race = 1 if race != 3 & race !=6 & hispanic == 1

*hispanic heritage but put white as main race
gen white_attritor = 0
replace white_attritor = 1 if attritor == 1 & race == 1

*same as above but not mixed race
gen white_attritor_single_race = 0
replace white_attritor_single_race = 1 if attritor_single_race == 1 & race == 1

*hispanic heritage but put black as main race
gen black_attritor = 0
replace black_attritor = 1 if attritor == 1 & race == 2

*same as above but not mixed race
gen black_attritor_single_race = 0
replace black_attritor_single_race = 1 if attritor_single_race == 1 & race == 2

**total racial resentment variable
recode wyt_ppl_adv (1=5) (2=4) (3=3) (4=2) (5=1), gen(rev_wyt_ppl_adv)
recode gen_slavery (1=5) (2=4) (3=3) (4=2) (5=1), gen(rev_gen_slavery)
**the smaller the number the more racial resentment/prejudice they have
gen racial_resentment = rev_wyt_ppl_adv + rare_iso + overcome_prejudice + rev_gen_slavery

gen racial_resentment_2 = overcome_prejudice + rev_gen_slavery

**recode for missingness
**variables: gender(done) year(done) employ() cit1() educ() religpew_catholic() pid3() faminc_new() race() attritor()

generate income_missing = .
replace income_missing = 1 if faminc_new == .
replace income_missing = 1 if faminc_new >16
**make it so missing is lumped in with the lowest but then controlled for
replace faminc_new = 1 if income_missing == 1

***now I can make a combo variable where you can separately analyze missing people and analyze income effect without losing 

**make employment missing variable - this is kind of weird because I don't know what other employment means. Is this just missing? I counted it as missing but that could be inaccurate
generate employ_missing = .
replace employ_missing = 1 if employ == .
replace employ_missing = 1 if employ == 9
replace employ_missing = 0 if employ <= 8
replace employ = 1 if employ_missing == 1

****now for citizenship

generate citizen_missing = .
replace citizen_missing = 1 if cit1 == 3
replace citizen_missing = 1 if cit1 == .
replace citizen_missing = 0 if cit1 <=2
replace cit1 = 1 if citizen_missing == 1

*label define cit_lbl ///
	2 "Yes" ///
	3 "No" ///
	1 "Missing"*

**LMFAO I WAS ONLY STUDYING CATHOLICS INSTEAD OF CONTROLLING FOR IT 
generate catholic = .
replace catholic = 1 if religpew_catholic == 1
replace catholic = 1 if religpew_catholic == 2
replace catholic = 1 if religpew_catholic == 3
replace catholic = 1 if religpew_catholic == 4
replace catholic = 1 if religpew_catholic == 5
replace catholic = 1 if religpew_catholic == 90
replace catholic = 0 if religpew_catholic == .

generate pid3_missing = .
replace pid3_missing = 1 if pid3 == .
replace pid3_missing = 0 if pid3 != .
replace pid3 = 1 if pid3_missing == 1

save recodemergeddata.dta, replace
*****
*****
*****
*****
*****time to merge the zipcode data using https://data.census.gov/table/ACSDP5Y2022.DP05?q=DP05&g=010XX00US$8600000 ZCTA w community survey data
import delimited "2022CensusZipcode.csv", clear
**make the percent hispanic is total hispanic divided by total
drop if v25 == "Estimate!!Total:!!Hispanic or Latino:"
drop if v25 == "B03002_012E"
destring v25, generate(v25_2)
destring v9, generate(v9_2)

***SOMETHING FUNKY HERE > why is there . ?
destring v3, generate(v3_2)
gen pct_hisp_zip = 100*v25_2/v3_2
recode pct_hisp_zip (.=0)
gen pct_black_zip = 100*v9_2/v3_2
recode pct_black_zip (.=0)

**create a substring of the zipcode variable so it doesn't have ZCTA5 at the start of everything
******calling it lookupzip to make merging easy
gen lookupzip = substr(v2, 7, .)

keep pct_hisp_zip lookupzip pct_black_zip

gen year = 2022

save zipdatasmall.dta, replace

**add 2020 data
import delimited "2020CensusZipcode.csv", clear
**make the percent hispanic is total hispanic divided by total
drop if v143 == "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)"
drop if v143 == "DP05_0071E"
destring v143, generate(v143_2)
**non latino + black
destring v157, generate(v157_2)

destring v141, generate(v141_2)
gen pct_hisp_zip = 100*v143_2/v141_2
recode pct_hisp_zip (.=0)
gen pct_black_zip = 100*v157_2/v141_2
recode pct_black_zip (.=0)

**create a substring of the zipcode variable so it doesn't have ZCTA5 at the start of everything
******calling it lookupzip to make merging easy
gen lookupzip = substr(v2, 7, .)

keep pct_hisp_zip lookupzip pct_black_zip

gen year = 2020

append using "zipdatasmall.dta"
save zipdatasmall.dta, replace

**add 2018 data
import delimited "2018CensusZipcode.csv", clear
**make the percent hispanic is total hispanic divided by total
drop if v143 == "Estimate!!HISPANIC OR LATINO AND RACE!!Total population!!Hispanic or Latino (of any race)"
drop if v143 == "DP05_0071E"
destring v143, generate(v143_2)
**non latino + black
destring v157, generate(v157_2)

destring v141, generate(v141_2)
gen pct_hisp_zip = 100*v143_2/v141_2
recode pct_hisp_zip (.=0)
gen pct_black_zip = 100*v157_2/v141_2
recode pct_black_zip (.=0)
**create a substring of the zipcode variable so it doesn't have ZCTA5 at the start of everything
******calling it lookupzip to make merging easy
gen lookupzip = substr(v2, 7, .)

keep pct_hisp_zip lookupzip pct_black_zip

gen year = 2018

append using "zipdatasmall.dta"
save zipdatasmall.dta, replace

gen lookupzip_clean = trim(lookupzip)
replace lookupzip = lookupzip_clean
drop lookupzip_clean


use "recodemergeddata.dta", clear
merge m:1 lookupzip year using zipdatasmall.dta

***could find a new dataset for these
generate weird_zip = 0
replace weird_zip = 1 if _merge == 1

drop if _merge == 2
drop _merge

generate democrat = 0
replace democrat = 1 if pid3 == 1

generate republican = 0 
replace republican = 1 if pid3 == 2

**variable for two party partisanship
generate twopartyvoter = .
replace twopartyvoter = 1 if pid3 == 1
replace twopartyvoter = 2 if pid3 == 2

**3 party id system where missingness/other is the lowest value
generate threepartyid = .
replace threepartyid = 1 if pid3 == 1
replace threepartyid = 3 if pid3 == 2
**combining independent and not sure into one measure - idk if thats valid or not?? - ask about this
replace threepartyid = 2 if pid3 == 3 
replace threepartyid = 2 if pid3 == 5
replace threepartyid = 0 if pid3 != 1 & pid3 != 2 & pid3 != 3 & pid3 != 5

***pid7 missingness
generate pid7_noanswer = 0
replace pid7_noanswer = 1 if pid7 == .
replace pid7_noanswer = 1 if pid7 == 8

***so the pid7 missing and other people are coded into strong democrat
replace pid7 = 1 if pid7_noanswer == 1

***marriage recode
generate marstatus_missing = 0
replace marstatus_missing = 1 if marstat == .
replace marstatus_missing = 1 if marstat > 6

**recode marstat missing into single
replace marstat = 1 if marstatus_missing == 1

gen single = .
replace single = 1 if marstat == 5
replace single = 0 if marstat != 5 

save recodemergeddata2.dta, replace

use "recodemergeddata2.dta", replace 

***rescale rescale rescale

**recode the fire scale so it makes more sense > bigger = more racist
recode overcome_prejudice (1=5) (2=4) (3=3) (4=2) (5=1), gen(rev_overcome_prejudice)

gen FIRE_scale = rev_overcome_prejudice + gen_slavery

**recode for missingness
generate FIREscale_missing = 0
replace FIREscale_missing = 1 if FIRE_scale == .

replace FIRE_scale = 0 if FIREscale_missing == 1

**rescale 0-1
egen FIRE_scale_min = min(FIRE_scale)
egen FIRE_scale_max = max(FIRE_scale)
gen FIRE_scale_rescaled = (FIRE_scale - FIRE_scale_min) / (FIRE_scale_max - FIRE_scale_min)

****gender should be a categorical variable from now on!11 i.gender
****should be using faminc not employ

**recode cit1 0-1
egen cit1_min = min(cit1)
egen cit1_max = max(cit1)
gen cit1_rescaled = (cit1 - cit1_min) / (cit1_max - cit1_min)

**recode faminc
egen faminc_min = min(faminc_new)
egen faminc_max = max(faminc_new)
gen faminc_rescaled = (faminc_new - faminc_min) / (faminc_max - faminc_min)

**recode educ
egen educ_min = min(educ)
egen educ_max = max(educ)
gen educ_rescaled = (educ - educ_min) / (educ_max - educ_min)

**recode pid7
egen pid7_min = min(pid7)
egen pid7_max = max(pid7)
gen pid7_rescaled = (pid7 - pid7_min) / (pid7_max - pid7_min)

**recode marstat
egen marstat_min = min(marstat)
egen marstat_max = max(marstat)
gen marstat_rescaled = (marstat - marstat_min) / (marstat_max - marstat_min)

**recode hisp zip missing
generate pct_hisp_zip_missing = 0
replace pct_hisp_zip_missing = 1 if pct_hisp_zip == .

replace pct_hisp_zip = 0 if pct_hisp_zip_missing == 1

**recode pct hisp zip
egen pct_hisp_zip_min = min(pct_hisp_zip)
egen pct_hisp_zip_max = max(pct_hisp_zip)
gen pct_hisp_zip_rescaled = (pct_hisp_zip - pct_hisp_zip_min) / (pct_hisp_zip_max - pct_hisp_zip_min)

**recode pct black zip missing
generate pct_black_zip_missing = 0
replace pct_black_zip_missing = 1 if pct_black_zip == .

replace pct_black_zip = 0 if pct_black_zip_missing == 1

**recode pct hisp zip
egen pct_black_zip_min = min(pct_black_zip)
egen pct_black_zip_max = max(pct_black_zip)
gen pct_black_zip_rescaled = (pct_black_zip - pct_black_zip_min) / (pct_black_zip_max - pct_black_zip_min)

**recode employ
egen employ_min = min(employ)
egen employ_max = max(employ)
gen employ_rescaled = (employ - employ_min) / (employ_max - employ_min)

**variables: resentment(done) gender(done, categorical) year(done) employ(replace w income, done) cit1(done) educ(done) religpew_catholic(done, na) pid3(replace w pid7, done) faminc_new(done) race(na) attritor(done) marstat

save recodeddata2.dta, replace
use "recodeddata2.dta", clear

**add age
**make a generations variable
gen generation = .
**GI
replace generation = 1 if birthyr < 1928
**silent
replace generation = 2 if birthyr > 1927 & birthyr < 1946 
**baby boom
replace generation = 3 if birthyr > 1945 & birthyr < 1965
**generation x
replace generation = 4 if birthyr > 1964 & birthyr < 1981
**millennial
replace generation = 5 if birthyr > 1979 & birthyr < 1997
**gen z
replace generation = 6 if birthyr > 1996

gen dominican = 0
replace dominican = 1 if CC22_hisp_6 == 1
replace dominican = 1 if CC18_354a_6 == 1
replace dominican = 1 if CC20_hisp_6 == 1

**fix gender
recode gender (4=3)

gen FIRE_black_int = FIRE_scale_rescaled*pct_black_zip_rescaled

save recodeddata3.dta, replace
use "recodeddata3.dta", clear
**fix gender
recode gender (4=3)

gen ideo5_missing = 0
replace ideo5_missing = 1 if ideo5_ == .
**recoded ideo5 on 1/23 so not sure = 0 instead of 1
replace ideo5_missing = 1 if ideo5_ == 6
recode ideo5 (6=3)
egen ideo5_min = min(ideo5)
egen ideo5_max = max(ideo5)
gen ideo5_rescaled = (ideo5 - ideo5_min) / (ideo5_max - ideo5_min)

***thesis chapter descriptive stats
svy: tab FIRE_scale_rescaled
*svy: sum FIRE_scale_rescaled
svy: tab FIRE_scale_rescaled if hispanic == 1
svy: tab FIRE_scale_rescaled white_attritor_single_race if hispanic == 1
*svy: sum FIRE_scale_rescaled white_attritor_single_race if hispanic == 1
svy: tab FIRE_scale_rescaled black_attritor_single_race if hispanic == 1
*svy: sum FIRE_scale_rescaled black_attritor_single_race if hispanic == 1
svy: tab FIRE_scale_rescaled attritor_single_race if hispanic == 1
*svy: sum FIRE_scale_rescaled if attritor_single_race == 0 & hispanic == 1

svy: tab educ white_attritor_single_race if hispanic == 1
svy: tab educ black_attritor_single_race if hispanic == 1
svy: tab educ if attritor_single_race == 0 & hispanic == 1
*svy: sum educ if black_attritor_single_race == 1
*svy: sum educ if white_attritor_single_race == 1

svy: tab pid7_rescaled if attritor_single_race == 0 & hispanic == 1
svy: tab pid7_rescaled if white_attritor_single_race == 1
svy: tab pid7_rescaled if black_attritor_single_race == 1

svy: tab generation if white_attritor_single_race == 1
svy: tab generation if black_attritor_single_race == 1
svy: tab generation if attritor_single_race == 0 & hispanic == 1

svy: tab gender if white_attritor_single_race == 1
svy: tab gender if black_attritor_single_race == 1
svy: tab gender if attritor_single_race == 0 & hispanic == 1

svy: tab year if white_attritor_single_race == 1
svy: tab year if black_attritor_single_race == 1
svy: tab year if attritor_single_race == 0 & hispanic == 1

svy: tab faminc_new if white_attritor_single_race == 1
svy: tab faminc_new if black_attritor_single_race == 1
svy: tab faminc_new if attritor_single_race == 0 & hispanic == 1

svy: tab cit1 if white_attritor_single_race == 1
svy: tab cit1 if black_attritor_single_race == 1
svy: tab cit1 if attritor_single_race == 0 & hispanic == 1

svy: tab catholic if white_attritor_single_race == 1
svy: tab catholic if black_attritor_single_race == 1
svy: tab catholic if attritor_single_race == 0 & hispanic == 1

svy: tab marstat if white_attritor_single_race == 1
svy: tab marstat if black_attritor_single_race == 1
svy: tab marstat if attritor_single_race == 0 & hispanic == 1

sum pct_hisp_zip if race == 3 & attritor_single_race == 0
sum pct_hisp_zip if white_attritor_single_race == 1
sum pct_hisp_zip if black_attritor_single_race == 1
sum pct_black_zip if race == 3 & attritor_single_race == 0
sum pct_black_zip if white_attritor_single_race == 1
sum pct_black_zip if black_attritor_single_race == 1

***thesis power analysis
**use 1737 stats test for minimal detectable effect
svy: mean FIRE_scale_rescaled if race == 1 & attritor_single_race == 0
estat sd
svy: mean FIRE_scale_rescaled if race == 2 & attritor_single_race == 0
estat sd
svy: mean FIRE_scale_rescaled if hispanic == 1 & attritor_single_race == 0 
estat sd
svy: mean FIRE_scale_rescaled if white_attritor_single_race == 1
estat sd
svy: mean FIRE_scale_rescaled if black_attritor_single_race == 1
estat sd

**power vs hispanics generally
power twomeans 0.444614, power(0.9) n(5000 6000 7000 8000) sd(0.3436611) graph

power twomeans 0.444614, power(0.9) n(1400 6000 7000 8000) sd(0.3436611) graph

**power vs hispancis for white attritors
power twomeans 0.444614 0.4700633, sd1(0.4336611) sd2(0.3597173) n1(4272) n2(3313) graph

**power vs hispanics for black attritors
power twomeans 0.444614 0.2813328, sd1(0.4336611) sd2(0.3105077) n1(4272) n2(599) graph

**power vs whites
power twomeans 0.5808958, power(0.9) n(5000 6000 7000 8000) sd(0.33942) graph

**power vs blacks
power twomeans 0.3206017, power(0.9) n(1500 5000 6000 7000) sd(0.2664457) graph

ssc install outreg2

***thesis regressions
***model A no controls whiteness
svy: regress white_attritor_single_race FIRE_scale_rescaled if hispanic == 1 & black_attritor_single_race == 0
outreg2 using "regtable21.doc"

***model B w controls
svy: regress white_attritor_single_race FIRE_scale_rescaled pid7_rescaled pid7_noanswer ideo5_rescaled ideo5_missing i.gender i.year generation faminc_rescaled cit1_rescaled citizen_missing educ_rescaled catholic marstat_rescaled marstatus_missing pct_hisp_zip_rescaled pct_hisp_zip_missing pct_black_zip_rescaled pct_black_zip_missing if hispanic == 1 & black_attritor_single_race == 0
outreg2 using "regtable22.doc"

svy: regress white_attritor_single_race FIRE_scale_rescaled pid7_rescaled pid7_noanswer i.gender i.year generation faminc_rescaled cit1_rescaled citizen_missing educ_rescaled catholic marstat_rescaled marstatus_missing pct_hisp_zip pct_hisp_zip_missing pct_black_zip pct_black_zip_missing if hispanic == 1 & black_attritor_single_race == 0

outreg2 using "regtable24.doc"

***model C no controls blackness
svy: regress black_attritor_single_race FIRE_scale_rescaled if hispanic == 1 & white_attritor_single_race == 0
outreg2 using "regtable25.doc"

tab race if hispanic == 1 & white_attritor_single_race == 0 & black_attritor_single_race == 0

***model D controls
svy: regress black_attritor_single_race FIRE_scale_rescaled dominican pid7_rescaled pid7_noanswer ideo5_rescaled ideo5_missing i.gender i.year generation faminc_rescaled cit1_rescaled citizen_missing educ_rescaled catholic marstat_rescaled marstatus_missing pct_hisp_zip_rescaled pct_hisp_zip_missing pct_black_zip_rescaled pct_black_zip_missing if hispanic == 1 & white_attritor_single_race == 0
outreg2 using "regtable26.doc"


***robustness checks

***probit
***model A no controls whiteness
svy: probit white_attritor_single_race FIRE_scale_rescaled if hispanic == 1 & black_attritor_single_race == 0
outreg2 using "robustregtable1.doc"

***model B w controls
svy: probit white_attritor_single_race FIRE_scale_rescaled pid7_rescaled pid7_noanswer i.gender i.year generation faminc_rescaled cit1_rescaled citizen_missing educ_rescaled catholic marstat_rescaled marstatus_missing pct_hisp_zip_rescaled pct_hisp_zip_missing pct_black_zip_rescaled pct_black_zip_missing if hispanic == 1 & black_attritor_single_race == 0
outreg2 using "robustregtable2.doc"

svy: probit white_attritor_single_race FIRE_scale_rescaled pid7_rescaled pid7_noanswer i.gender i.year generation faminc_rescaled cit1_rescaled citizen_missing educ_rescaled catholic marstat_rescaled marstatus_missing pct_hisp_zip pct_hisp_zip_missing pct_black_zip pct_black_zip_missing if hispanic == 1 & black_attritor_single_race == 0

***model C no controls blackness
svy: probit black_attritor_single_race FIRE_scale_rescaled if hispanic == 1 & white_attritor_single_race == 0
outreg2 using "robustregtable3.doc"

tab race if hispanic == 1 & white_attritor_single_race == 0 & black_attritor_single_race == 0

***model D controls
svy: probit black_attritor_single_race FIRE_scale_rescaled dominican pid7_rescaled pid7_noanswer i.gender i.year generation faminc_rescaled cit1_rescaled citizen_missing educ_rescaled catholic marstat_rescaled marstatus_missing pct_hisp_zip_rescaled pct_hisp_zip_missing pct_black_zip_rescaled pct_black_zip_missing if hispanic == 1 & white_attritor_single_race == 0
outreg2 using "robustregtable4.doc"






gen pct_hisp = 0
**percentages are from https://www.kff.org/state-health-policy-data/state-indicator/distribution-by-raceethnicity/?currentTimeframe=1&sortModel=%7B%22colId%22:%22Location%22,%22sort%22:%22asc%22%7D using american community survey data from KFF
replace pct_hisp = 4.8  if state == 1  & year == 2022   // alabama (01)
replace pct_hisp = 7.3  if state == 2  & year == 2022   // alaska (02)
replace pct_hisp = 32.5 if state == 4  & year == 2022   // arizona (04)
replace pct_hisp = 8.5  if state == 5  & year == 2022   // arkansas (05)
replace pct_hisp = 40.4 if state == 6  & year == 2022   // california (06)
replace pct_hisp = 22.6 if state == 8  & year == 2022   // colorado (08)
replace pct_hisp = 18.3 if state == 9  & year == 2022   // connecticut (09)
replace pct_hisp = 10.3 if state == 10 & year == 2022   // delaware (10)
replace pct_hisp = 11.9 if state == 11 & year == 2022   // district of columbia (11)
replace pct_hisp = 27.3 if state == 12 & year == 2022   // florida (12)
replace pct_hisp = 10.4 if state == 13 & year == 2022   // georgia (13)
replace pct_hisp = 10.8 if state == 15 & year == 2022   // hawaii (15)
replace pct_hisp = 13.5 if state == 16 & year == 2022   // idaho (16)
replace pct_hisp = 18.4 if state == 17 & year == 2022   // illinois (17)
replace pct_hisp = 7.8  if state == 18 & year == 2022   // indiana (18)
replace pct_hisp = 6.8  if state == 19 & year == 2022   // iowa (19)
replace pct_hisp = 13.1 if state == 20 & year == 2022   // kansas (20)
replace pct_hisp = 4.1  if state == 21 & year == 2022   // kentucky (21)
replace pct_hisp = 5.7  if state == 22 & year == 2022   // louisiana (22)
replace pct_hisp = 2.0  if state == 23 & year == 2022   // maine (23)
replace pct_hisp = 11.5 if state == 24 & year == 2022   // maryland (24)
replace pct_hisp = 13.1 if state == 25 & year == 2022   // massachusetts (25)
replace pct_hisp = 5.7  if state == 26 & year == 2022   // michigan (26)
replace pct_hisp = 5.8  if state == 27 & year == 2022   // minnesota (27)
replace pct_hisp = 3.2  if state == 28 & year == 2022   // mississippi (28)
replace pct_hisp = 4.7  if state == 29 & year == 2022   // missouri (29)
replace pct_hisp = 4.3  if state == 30 & year == 2022   // montana (30)
replace pct_hisp = 12.3 if state == 31 & year == 2022   // nebraska (31)
replace pct_hisp = 30.3 if state == 32 & year == 2022   // nevada (32)
replace pct_hisp = 4.5  if state == 33 & year == 2022   // new hampshire (33)
replace pct_hisp = 22.0 if state == 34 & year == 2022   // new jersey (34)
replace pct_hisp = 50.5 if state == 35 & year == 2022   // new mexico (35)
replace pct_hisp = 19.7 if state == 36 & year == 2022   // new york (36)
replace pct_hisp = 10.4 if state == 37 & year == 2022   // north carolina (37)
replace pct_hisp = 4.4  if state == 38 & year == 2022   // north dakota (38)
replace pct_hisp = 4.4  if state == 39 & year == 2022   // ohio (39)
replace pct_hisp = 12.2 if state == 40 & year == 2022   // oklahoma (40)
replace pct_hisp = 14.4 if state == 41 & year == 2022   // oregon (41)
replace pct_hisp = 8.7  if state == 42 & year == 2022   // pennsylvania (42)
replace pct_hisp = 17.9 if state == 44 & year == 2022   // rhode island (44)
replace pct_hisp = 6.4  if state == 45 & year == 2022   // south carolina (45)
replace pct_hisp = 4.6  if state == 46 & year == 2022   // south dakota (46)
replace pct_hisp = 6.3  if state == 47 & year == 2022   // tennessee (47)
replace pct_hisp = 40.5 if state == 48 & year == 2022   // texas (48)
replace pct_hisp = 15.2 if state == 49 & year == 2022   // utah (49)
replace pct_hisp = 2.2  if state == 50 & year == 2022   // vermont (50)
replace pct_hisp = 10.4 if state == 51 & year == 2022   // virginia (51)
replace pct_hisp = 14.0 if state == 53 & year == 2022   // washington (53)
replace pct_hisp = 1.9  if state == 54 & year == 2022   // west virginia (54)
replace pct_hisp = 7.6  if state == 55 & year == 2022   // wisconsin (55)
replace pct_hisp = 10.9 if state == 56 & year == 2022   // wyoming (56)
**2020
**pcts here are from census directly https://data.census.gov/table?g=010XX00US$0400000_040XX00US01&d=DEC+Demographic+Profile
replace pct_hisp = 5.3 if state == 1  & year == 2020   // alabama (01)
replace pct_hisp = 6.8 if state == 2  & year == 2020   // alaska (02)
replace pct_hisp = 30.7 if state == 4  & year == 2020   // arizona (04)
replace pct_hisp = 8.5 if state == 5  & year == 2020   // arkansas (05)
replace pct_hisp = 39.4 if state == 6  & year == 2020   // california (06)
replace pct_hisp = 21.9 if state == 8  & year == 2020   // colorado (08)
replace pct_hisp = 17.3 if state == 9  & year == 2020   // connecticut (09)
replace pct_hisp = 10.5 if state == 10 & year == 2020   // delaware (10)
replace pct_hisp = 11.3 if state == 11 & year == 2020   // district of columbia (11)
replace pct_hisp = 26.5 if state == 12 & year == 2020   // florida (12)
replace pct_hisp = 10.5 if state == 13 & year == 2020   // georgia (13)
replace pct_hisp = 9.5 if state == 15 & year == 2020   // hawaii (15)
replace pct_hisp = 13.0 if state == 16 & year == 2020   // idaho (16)
replace pct_hisp = 18.2 if state == 17 & year == 2020   // illinois (17)
replace pct_hisp = 8.2 if state == 18 & year == 2020   // indiana (18)
replace pct_hisp = 6.8 if state == 19 & year == 2020   // iowa (19)
replace pct_hisp = 13.0 if state == 20 & year == 2020   // kansas (20)
replace pct_hisp = 4.6 if state == 21 & year == 2020   // kentucky (21)
replace pct_hisp = 6.9 if state == 22 & year == 2020   // louisiana (22)
replace pct_hisp = 2.0 if state == 23 & year == 2020   // maine (23)
replace pct_hisp = 11.8 if state == 24 & year == 2020   // maryland (24)
replace pct_hisp = 12.6 if state == 25 & year == 2020   // massachusetts (25)
replace pct_hisp = 5.6 if state == 26 & year == 2020   // michigan (26)
replace pct_hisp = 6.1 if state == 27 & year == 2020   // minnesota (27)
replace pct_hisp = 3.6 if state == 28 & year == 2020   // mississippi (28)
replace pct_hisp = 4.9 if state == 29 & year == 2020   // missouri (29)
replace pct_hisp = 4.2 if state == 30 & year == 2020   // montana (30)
replace pct_hisp = 12.0 if state == 31 & year == 2020   // nebraska (31)
replace pct_hisp = 28.7 if state == 32 & year == 2020   // nevada (32)
replace pct_hisp = 4.3 if state == 33 & year == 2020   // new hampshire (33)
replace pct_hisp = 21.6 if state == 34 & year == 2020   // new jersey (34)
replace pct_hisp = 47.7 if state == 35 & year == 2020   // new mexico (35)
replace pct_hisp = 19.5 if state == 36 & year == 2020   // new york (36)
replace pct_hisp = 10.7 if state == 37 & year == 2020   // north carolina (37)
replace pct_hisp = 4.3 if state == 38 & year == 2020   // north dakota (38)
replace pct_hisp = 4.4 if state == 39 & year == 2020   // ohio (39)
replace pct_hisp = 11.9 if state == 40 & year == 2020   // oklahoma (40)
replace pct_hisp = 13.9 if state == 41 & year == 2020   // oregon (41)
replace pct_hisp = 8.1 if state == 42 & year == 2020   // pennsylvania (42)
replace pct_hisp = 16.6 if state == 44 & year == 2020   // rhode island (44)
replace pct_hisp = 6.9 if state == 45 & year == 2020   // south carolina (45)
replace pct_hisp = 4.4 if state == 46 & year == 2020   // south dakota (46)
replace pct_hisp = 6.9 if state == 47 & year == 2020   // tennessee (47)
replace pct_hisp = 39.3 if state == 48 & year == 2020   // texas (48)
replace pct_hisp = 15.1 if state == 49 & year == 2020   // utah (49)
replace pct_hisp = 2.4 if state == 50 & year == 2020   // vermont (50)
replace pct_hisp = 10.5 if state == 51 & year == 2020   // virginia (51)
replace pct_hisp = 13.7 if state == 53 & year == 2020   // washington (53)
replace pct_hisp = 1.9 if state == 54 & year == 2020   // west virginia (54)
replace pct_hisp = 7.6 if state == 55 & year == 2020   // wisconsin (55)
replace pct_hisp = 10.2 if state == 56 & year == 2020   // wyoming (56)
*****2018
*****from the KFF again
replace pct_hisp = 4.3   if state == 1  & year == 2018
replace pct_hisp = 7.1   if state == 2  & year == 2018
replace pct_hisp = 31.6  if state == 4  & year == 2018
replace pct_hisp = 7.7   if state == 5  & year == 2018
replace pct_hisp = 39.4  if state == 6  & year == 2018
replace pct_hisp = 21.6  if state == 8  & year == 2018
replace pct_hisp = 16.6  if state == 9  & year == 2018
replace pct_hisp = 9.5   if state == 10 & year == 2018
replace pct_hisp = 11.3  if state == 11 & year == 2018
replace pct_hisp = 26.3  if state == 12 & year == 2018
replace pct_hisp = 9.7   if state == 13 & year == 2018
replace pct_hisp = 10.5  if state == 15 & year == 2018
replace pct_hisp = 12.7  if state == 16 & year == 2018
replace pct_hisp = 17.5  if state == 17 & year == 2018
replace pct_hisp = 7.1   if state == 18 & year == 2018
replace pct_hisp = 6.1   if state == 19 & year == 2018
replace pct_hisp = 12.0  if state == 20 & year == 2018
replace pct_hisp = 3.6   if state == 21 & year == 2018
replace pct_hisp = 5.1   if state == 22 & year == 2018
replace pct_hisp = 1.5   if state == 23 & year == 2018
replace pct_hisp = 10.5  if state == 24 & year == 2018
replace pct_hisp = 12.4  if state == 25 & year == 2018
replace pct_hisp = 5.2   if state == 26 & year == 2018
replace pct_hisp = 5.4   if state == 27 & year == 2018
replace pct_hisp = 2.8   if state == 28 & year == 2018
replace pct_hisp = 4.1   if state == 29 & year == 2018
replace pct_hisp = 3.9   if state == 30 & year == 2018
replace pct_hisp = 11.1  if state == 31 & year == 2018
replace pct_hisp = 29.1  if state == 32 & year == 2018
replace pct_hisp = 3.8   if state == 33 & year == 2018
replace pct_hisp = 20.8  if state == 34 & year == 2018
replace pct_hisp = 49.1  if state == 35 & year == 2018
replace pct_hisp = 19.3  if state == 36 & year == 2018
replace pct_hisp = 9.6   if state == 37 & year == 2018
replace pct_hisp = 3.5   if state == 38 & year == 2018
replace pct_hisp = 3.8   if state == 39 & year == 2018
replace pct_hisp = 10.9  if state == 40 & year == 2018
replace pct_hisp = 13.3  if state == 41 & year == 2018
replace pct_hisp = 7.6   if state == 42 & year == 2018
replace pct_hisp = 16.0  if state == 44 & year == 2018
replace pct_hisp = 5.8   if state == 45 & year == 2018
replace pct_hisp = 3.8   if state == 46 & year == 2018
replace pct_hisp = 5.5   if state == 47 & year == 2018
replace pct_hisp = 39.8  if state == 48 & year == 2018
replace pct_hisp = 14.1  if state == 49 & year == 2018
replace pct_hisp = 1.8   if state == 50 & year == 2018
replace pct_hisp = 9.5   if state == 51 & year == 2018
replace pct_hisp = 12.9  if state == 53 & year == 2018
replace pct_hisp = 1.3   if state == 54 & year == 2018
replace pct_hisp = 7.0   if state == 55 & year == 2018
replace pct_hisp = 10.0  if state == 56 & year == 2018

***pct_hisp is v significant



Partisan identification. 

Percentage Hispanic in zipcode (pct Hispanic zip).

Percentage black in zip code (pct black zip).

Dominican.

Catholic.

Citizenship.

Education.

Marital status.

Survey year.

Generation.

Family income. 

Gender.

Missingness variables (XYZ).

